import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('piniaCart', () => {

let piniaCart=ref([])
let piniaAddCart=(detailData,goods_id)=>{
let username=localStorage.getItem('username')
let pdCart=piniaAddCart.value(item=>item.goods_id==goods_id)
if(pdCart){
pdCart.value++
}else{
pdCart.value.push({
   username:username,
   id:Math.floor(Math.random()*100000),
   num:1,
   goods:detailData,
   checked:false,
}
)
}
}
  return { piniaCart,piniaAddCart}
},
  {
    persist: true,
  },
)
